cmake_minimum_required( VERSION 2.8 )
project("knkd")

add_subdirectory( plugins/dbconnector_mysql dbconnector_mysql )

find_package( Qt4 REQUIRED )
include( ${QT_USE_FILE} )
INCLUDE_DIRECTORIES(
    ${QT_INCLUDE_DIR}
    ${CMAKE_CURRENT_BINARY_DIR}
    ../qxmlrpc
    interfaces
)
# генерируем деф файл

#check_include_file_cxx("def.h" HAVE_DEF)

set(INSTPREF ${CMAKE_INSTALL_PREFIX})
configure_file(def.h.in def.h)

set( HEADERS
        mlog.h
        xserver.h
)

set( CPPS
        main.cpp
        mlog.cpp
        xserver.cpp
)

qt4_wrap_cpp( MOC_SOURCES ${HEADERS} )

add_executable( knkd ${CPPS} ${MOC_SOURCES} ${UIS_H} ) 

target_link_libraries( knkd ${QT_QTCORE_LIBRARIES} ${QT_QTSQL_LIBRARIES} qxmlrpc)

# install for linux
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
    set(rootdir ${CMAKE_INSTALL_PREFIX})
    set(rootdir_bin ${rootdir}/bin)
    install(TARGETS knkd DESTINATION ${rootdir_bin})
endif()
# install for mac os x
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
    set(rootdir ${CMAKE_INSTALL_PREFIX})
    set(rootdir_bin ${rootdir}/bin)
    install(TARGETS knkd DESTINATION ${rootdir_bin})
endif()

